package com.ds.duizhang20221212.util;

import com.ds.duizhang20221212.dto.支付宝ExcelDTO;
import com.ds.duizhang20221212.dto.银行流水ExcelDTO;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;

public class Util {
    static String zfbCacheFile = "C:\\qh\\log\\zfb.txt";
    static String bankCacheFile = "C:\\qh\\log\\bank.txt";

    public static void writeZfbData2Local(Object obj) {
        try (//创建一个ObjectOutputStream输出流
             ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(zfbCacheFile))) {
            oos.writeObject(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void writeBankData2Local(Object obj) {
        try (//创建一个ObjectOutputStream输出流
             ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(bankCacheFile))) {
            oos.writeObject(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static List<支付宝ExcelDTO> readZfbDataFromCache() throws Exception {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(zfbCacheFile));
        List<支付宝ExcelDTO> 支付宝流水 = (List<支付宝ExcelDTO>) ois.readObject();
        return 支付宝流水;
    }

    public static List<银行流水ExcelDTO> readBankDataFromCache() throws Exception {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(bankCacheFile));
        List<银行流水ExcelDTO> 流水 = (List<银行流水ExcelDTO>) ois.readObject();
        return 流水;
    }


}
